#ifndef INTEGRATOR_H
#define INTEGRATOR_H

#include <vec3.h>
#include <mat3.h>
#include <vector>

#define SPECTRUM	50
#define TOLERATE	1e-3
#define TEMPSCALE	363

using namespace std;

class Stiff
{
public:
	Stiff();
	~Stiff();

	mat3f stiff;
	int index[2];
};

typedef vector<Stiff*> StiffChain;

class Integrator
{
public:
	Integrator(void);
	~Integrator(void);
	void InitSparseStiffness(int scale);
	void SparseSolver();
	void JacobiIter();
	void CheckJacobi();
	void CheckCG();
	void CheckGaussElimination();

	StiffChain** sparse_M;

	float*		ls_b;
	float**		ls_A;
	float*		ls_buffer;
	float*		ls_x;
	int**		ls_index;

	float		check_A[TEMPSCALE][TEMPSCALE];
	float		check_b[TEMPSCALE];
	float		check_buffer[TEMPSCALE];
	float		check_x[TEMPSCALE];
	float		check_residual[TEMPSCALE];
	float		check_p[TEMPSCALE];
	float		check_residual_cache[TEMPSCALE];
	float		GS[TEMPSCALE][TEMPSCALE+1];

	int scale;
};

#endif

